package com.woniuxy.config;

import com.woniuxy.util.JWTUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;

/**
 * @BelongsProject: pigTrotterStore
 * @BelongsPackage: com.woniuxy.config
 * @Author: Quan
 * @Date: 2025/3/13 19:07
 */
//@Configuration
public class getUserIdFromJwtConfig {
	@Autowired
	private HttpServletRequest request;

	@Bean
	@Scope("prototype")
	public Integer getUserIdFromJwt() throws ParseException {

		String token = request.getHeader("token");
		return JWTUtil.getUserId(token);
	}
}
